import QtQuick
import Qt5Compat.GraphicalEffects

Rectangle {
    id: toolTipButton
    property bool isHover: false
    property bool isClick: false
    property string iconSource
    property string iconColor: p_theme.currentTheme().fontColor
    property int size: 40
    property double iconScale: 0.5

    radius: size / 2
    width: size
    height: size
    color: isHover ? ("#1F" + p_theme.currentTheme().subBackgroundColor2) : "#00000000"
    scale: isClick ? 0.95 : (isHover ? 1.1 : 1)
    signal click
    Behavior on color {

        ColorAnimation {
            easing.type: Easing.InOutBounce
            duration: 200
        }
    }
    Behavior on scale {
        NumberAnimation {
            easing.type: Easing.InOutBounce
            duration: 200
        }
    }

    Image {
        id: icon
        anchors.centerIn: parent
        width: Math.floor(size * iconScale)
        height: Math.floor(size * iconScale)
        source: iconSource
        ColorOverlay {
            anchors.fill: parent
            color: iconColor
            source: parent
            Behavior on color {
                ColorAnimation {
                    easing.type: Easing.InOutBounce
                    duration: 200
                }
            }
        }
    }
    MouseArea {
        anchors.fill: parent
        hoverEnabled: true
        cursorShape: Qt.PointingHandCursor
        onEntered: {
            isHover = true;
        }
        onExited: {
            isHover = false;
        }

        onPressed: {
            isClick = true;
        }
        onReleased: {
            isClick = false;
        }
        onClicked: {
            toolTipButton.click();
        }
    }
}
